/*
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-06 17:18:37
 * @LastEditTime: 2021-12-06 17:36:29
 * @LastEditors: 赵大壮
 */
import { Component, Vue, Inject } from "vue-property-decorator";
import DZServiceAssess from "../../service/DZServiceAssess";
import UiDialogAddAssess from "@/components/ui-dialog/UiDialogAddAssess.vue"
import DZModelAssess from "../../model/DZModelAssess";

@Component({
    components: { UiDialogAddAssess }
})
export default class Index extends Vue {

    s_assess = new DZServiceAssess();

    dialog_add_assess = false;

    dialog_data = new DZModelAssess();

    created() { }

    mounted() {
        this.action_list_assess();
    }

    beforeDestroy() {

    }

    action_list_assess() {
        this.s_assess.net_list_assess();
    }
    action_page_change(page) {
        this.s_assess.m_page.page = page;
        this.action_list_assess();
    }

    action_page_question(item) {
        this.$router.push({ path: '/assess/question', query: { id: item.id, name: item.name, option: item.option, father: this.$route.path } });

    }
    action_page_rule(item) {
        this.$router.push({ path: '/assess/rule', query: { id: item.id, name: item.name, father: this.$route.path } });
    }
    action_edit_assess(item: DZModelAssess) {
        this.dialog_data = JSON.parse(JSON.stringify(item));
        this.dialog_add_assess = true;
    }

    action_assess_item_click(command, item) {
        switch (parseInt(command)) {
            case 1:
                this.action_page_question(item)
                break;
            case 2:
                this.action_page_rule(item)
                break;
            case 3:
                this.action_edit_assess(item)
                break;
        }
    }
    action_add_assess(isEdit: boolean, item: DZModelAssess) {
        this.s_assess.m_assess = item;
        if (isEdit) {
            this.s_assess.net_edit_assess(() => {
                this.dialog_add_assess = false
                this.action_list_assess();
            });
        } else {
            this.s_assess.net_add_assess(() => {
                this.dialog_add_assess = false
                this.action_list_assess();
            });
        }

    }
}